//
//  YYJLAnalysisController.m
//  YuanyangJinlou
//
//  Created by mac004 on 2017/1/9.
//  Copyright © 2017年 suli19910309@qq.com. All rights reserved.
//

#import "YYJLAnalysisController.h"

@interface YYJLAnalysisController ()
{
    UIScrollView * _scrollview;
    UILabel * titleLb;//考试类型
    UILabel * timeLb;//考试时间
    NSMutableArray * dateSourceArr;//全部数据
    NSArray * currentArray;//当前试题数据
    UILabel * questionLb;//问题
    UILabel * optionA;//选项A
    UILabel * optionB;//选项B
    UILabel * optionC;//选项C
    UILabel * optionD;//选项D
    UIButton * btnA;
    UIButton * btnB;
    UIButton * btnC;
    UIButton * btnD;
    UILabel  * resultLb;//答案
    UILabel  * analysisLb;//分析
}
@end

@implementation YYJLAnalysisController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    if (self.style==AnalysisAll) {
        [self setTitleView:@"全部解析"];
    }else{
        [self setTitleView:@"错题解析"];
    }
    [self setBackItem];
    
    [self creatUI];
}
-(void)creatUI{
    _scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT-44*PER_HEIGHT)];
    _scrollview.backgroundColor=[UIColor clearColor];
    [self.view addSubview:_scrollview];
    
    UIView * bgView=[[UIView alloc]initWithFrame:CGRectMake(12*PER_WIDTH, 0, _scrollview.width-24*PER_WIDTH, _scrollview.height-74*PER_HEIGHT)];
    bgView.backgroundColor=[UIColor whiteColor];
    bgView.layer.cornerRadius=10;
    bgView.layer.masksToBounds=YES;
    [_scrollview addSubview:bgView];
    
    titleLb=[MyControl createLabelWithFrame:CGRectMake(12*PER_WIDTH, 15*PER_HEIGHT, bgView.width-24*PER_WIDTH, 15*PER_HEIGHT) Font:15 Text:@"2016年11月考试试题" Color:TINK_COLOR];
    [bgView addSubview:titleLb];
    
  //半圆分割线
    UIImageView * round1=[[UIImageView alloc]initWithFrame:CGRectMake(4*PER_WIDTH, 27*PER_HEIGHT, 367*PER_WIDTH, 16*PER_WIDTH)];
    round1.image=[UIImage imageNamed:@"bg_fenge"];//367*16
    [_scrollview addSubview:round1];

    
   //答题区域
    questionLb=[MyControl createLabelWithFrame:CGRectMake(titleLb.left, titleLb.bottom+15*PER_HEIGHT, bgView.width-24*PER_WIDTH, 100) Font:14 Text:@"1,趣味答题趣味答题趣味答题趣味答题趣味答题,,趣味答题趣味答题趣味答题" Color:BLACK_COLOR];
    
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
    style.lineSpacing = 4*PER_HEIGHT;
    style.alignment = NSTextAlignmentLeft;
    NSMutableAttributedString *mutStr = [[NSMutableAttributedString alloc]initWithString:questionLb.text];
    [mutStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.f] range:NSMakeRange(0, questionLb.text.length)];
    [mutStr addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, questionLb.text.length)];
    questionLb. attributedText = mutStr;
    questionLb.numberOfLines=0;
    
    float nickHeight = [mutStr boundingRectWithSize:CGSizeMake(SCREEN_WIDTH-24*PER_WIDTH, 1000) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading context:nil].size.height;
    
    questionLb.frame=CGRectMake(titleLb.left, titleLb.bottom+15*PER_HEIGHT, bgView.width-24*PER_WIDTH, nickHeight );
    
    [bgView addSubview:questionLb];
    
    UIImage * imgA =[UIImage imageNamed:@"A_nor"];//29*29
    
    //A选项
    btnA=[MyControl createButtonWithFrame:CGRectMake( questionLb.left, questionLb.bottom+22*PER_HEIGHT,imgA.size.width*PER_WIDTH, imgA.size.width*PER_WIDTH) ImageName:@"A_nor" Target:self Action:@selector(btnClick:) Title:@""];
    btnA.tag=1;
    [bgView addSubview:btnA];
    
    optionA=[MyControl createLabelWithFrame:CGRectMake(btnA.right+15*PER_WIDTH, questionLb.bottom+30*PER_HEIGHT, SCREEN_WIDTH-(btnA.right+27*PER_WIDTH), 15*PER_HEIGHT) Font:15 Text:@"裂纹" Color:BLACK_COLOR];
    [bgView addSubview:optionA];
    
    //B选项
    optionB=[MyControl createLabelWithFrame:CGRectMake(optionA.left, optionA.bottom+36*PER_HEIGHT, optionA.width, optionA.height) Font:15 Text:@"失去灵性" Color:BLACK_COLOR];
    [bgView addSubview:optionB];
    
     btnB=[MyControl createButtonWithFrame:CGRectMake(optionB.left-15*PER_WIDTH-imgA.size.width*PER_WIDTH,optionB.top-8*PER_HEIGHT, imgA.size.width*PER_WIDTH, imgA.size.width*PER_WIDTH) ImageName:@"B_nor" Target:self Action:@selector(btnClick:) Title:@""];
    btnB.tag=2;
    [bgView addSubview:btnB];
    
    //C选项
    optionC=[MyControl createLabelWithFrame:CGRectMake(optionB.left, optionB.bottom+36*PER_HEIGHT, optionB.width, optionB.height) Font:15 Text:@"变黑" Color:BLACK_COLOR];
    [bgView addSubview:optionC];
    
     btnC=[MyControl createButtonWithFrame:CGRectMake(questionLb.left, optionC.top-8*PER_HEIGHT, imgA.size.width*PER_WIDTH, imgA.size.width*PER_WIDTH) ImageName:@"C_nor" Target:self Action:@selector(btnClick:) Title:@""];
    btnC.tag=3;
    [bgView addSubview:btnC];
    
    //D选项
    optionD=[MyControl createLabelWithFrame:CGRectMake(optionC.left, optionC.bottom+36*PER_HEIGHT, optionC.width, optionC.height) Font:15 Text:@"发白" Color:BLACK_COLOR];
    [bgView addSubview:optionD];
    
    
     btnD=[MyControl createButtonWithFrame:CGRectMake(questionLb.left, optionD.top-8*PER_HEIGHT, imgA.size.width*PER_WIDTH, imgA.size.width*PER_WIDTH) ImageName:@"D_nor" Target:self Action:@selector(btnClick:) Title:@""];
    btnD.tag=4;
    [bgView addSubview:btnD];
    //分割线
    UIView * lineS=[[UIView alloc]initWithFrame:CGRectMake(8*PER_WIDTH, optionD.bottom+40*PER_HEIGHT, bgView.width-16*PER_WIDTH, 0.5)];
    lineS.backgroundColor=UIColorFromHex(0xcccccc);
    [bgView addSubview:lineS];
    
    //分析区域
    resultLb=[MyControl createLabelWithFrame:CGRectMake(questionLb.left, lineS.bottom+15*PER_HEIGHT, bgView.width-24*PER_WIDTH, 14*PER_HEIGHT) Font:14 Text:@"正确答案为A,你的答案为C,回答错误" Color:BLACK_COLOR];
    [bgView addSubview:resultLb];
    
    UILabel * fenxiLb=[MyControl createLabelWithFrame:CGRectMake(questionLb.left, resultLb.bottom+25*PER_HEIGHT, 100, 15*PER_HEIGHT) Font:15 Text:@"答案解析" Color:TINK_COLOR];
    [bgView addSubview:fenxiLb];
    
    analysisLb=[MyControl createLabelWithFrame:CGRectMake(questionLb.left, fenxiLb.bottom+10*PER_HEIGHT, bgView.width-24*PER_WIDTH, 40*PER_HEIGHT) Font:14 Text:@"软玉的比重(3.00)略比翡翠的比重为低软玉的比重(3.00)略比翡翠的比重低" Color:BLACK_COLOR];
    analysisLb.numberOfLines=0;
    [bgView addSubview:analysisLb];
   
    //分割线
    UIView * line =[[UIView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT-44*PER_HEIGHT, SCREEN_WIDTH, 0.5)];
    line.backgroundColor=UIColorFromHex(0xcccccc);
    [self.view addSubview:line];
    //上一题
    UIButton * aboveBtn=[MyControl createButtonWithFrame:CGRectMake(questionLb.left, SCREEN_HEIGHT-29.5*PER_HEIGHT, 45*PER_WIDTH, 15*PER_HEIGHT) ImageName:@"" Target:self Action:@selector(aboveBtn) Title:@"上一题"];
    [aboveBtn setTitleColor:FEELT_COLOR forState:0];
    aboveBtn.titleLabel.font=[UIFont systemFontOfSize:15*PER_HEIGHT];
    [self.view addSubview:aboveBtn];
    //下一题
    UIButton * nextBtn=[MyControl createButtonWithFrame:CGRectMake(SCREEN_WIDTH-12*PER_WIDTH-45*PER_WIDTH, aboveBtn.top, aboveBtn.width, aboveBtn.height) ImageName:@"" Target:self Action:@selector(nextBtn) Title:@"下一题"];
    [nextBtn setTitleColor:FEELT_COLOR forState:0];
    nextBtn.titleLabel.font=[UIFont systemFontOfSize:15*PER_HEIGHT];
    [self.view addSubview:nextBtn];

    
}
#pragma mark---选择选项,插入到本地数据库
-(void)btnClick:(UIButton*)sender{
    
}
#pragma mark--上一题,下一题
-(void)aboveBtn{
    
}
-(void)nextBtn{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
